package com.dragon.web.commons.controller;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dragon.web.commons.constant.ErrorCode;
import com.dragon.web.commons.dto.VerifyDTO;
import com.fintech.common.util.PicVerifyUtils;
import com.fintech.common.util.RedisUtils;
import com.fintech.common.vo.FintechResult;

@Controller
@RequestMapping("${platform.name.code}/msg")
public class MessageController {
	/**
	 * 获取验证码 get/pictureVerify
	 * 
	 * @param accessToken
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "get/pictureVerify")
	public FintechResult getPictureVerify(@RequestBody VerifyDTO verifyDTO) {
		Map<String, Object> resultMap = new HashMap<>();
		Map<String, String> codeAndPicBase64 = PicVerifyUtils.getCodeAndPicBase64();
		String key = verifyDTO.getMobile() + "pic";
		RedisUtils.getInstance().set(key, codeAndPicBase64.get("code"));
		resultMap.put("imageBase64", codeAndPicBase64.get("imageBase64"));
		return FintechResult.getResult(ErrorCode.SUCCESS, "操作成功", resultMap);
	}

}
